Jetfire Overview

Modified on 2010/12/23 13:57 by John — Categorized as: Roles, States, Versioning

Jetfire Overview

Jetfire is a dynamic, multi-user, object oriented language and runtime support. The language derives its syntax from C# and Java. Jetfire extends this syntax by adding first class support for features such as states, roles, versioning, audit information and persistence. Objects and classes (code) in Jetfire are automatically and transparently placed in permanent storage on a server nexus. This storage can either be a file system, memory(sandbox applications) or a database.

Jetfire is well suited for workflow and policy based management applications (see Rules). Applications tend to be small with typical sizes consisting of 50 to several hundred lines of Jetfire code. This makes applications easy to write, maintain and supports validation through inspection. The interface to Jetfire from .net applications consists a few overloaded methods ('New', 'Get', 'Set' and 'Execute') that can be called directly. Alternately Jetfire Web Parts can be used to interface to Jetfire applications without writting an application interface.

Jetfire objects, once created, exist until they are explicitly deleted or they become unreferenced (even then the objects will still exist in archive storage). This feature allows workflows (objects) to be created that have a lifetime of days, weeks, months or even years. These objects will survive machine crashes, computer reboots and program reloads.

Since code may need to change over time Jetfire has built-in versioning for classes. Objects created with an old version of code will continue execute the old code unless the objects are explicitly upgraded.
Image

Hello World



The following is an example of Jetfire code.

// A very simple Jetfire workflow (class)
// This code can be selected, copied (cntrl c) and pasted (cntrl v) into the Jetfire dashboard.
namespace test
{
   workflow HelloWorld
   {
      DateTime creationTime = DateTime.Now;
      public string Hello
      {
           get{return "This workflow was created at:" + creationTime.ToString();}
      }
   }   
}
The significant difference between the workflow above and C#, is that when the workflow is instantiated (new), the resulting object is persistent (it is held in permanent storage such as a hard drive file or database). That is the created object is permanent and exists until it is explicitly removed or it is collected by the garbage collector. This permanent storage area is called a Jetfire 'workspace'. Try it for yourself. Create a number of instances of the above workflow using the Jetfire dashboard. Exit the dashboard and start the dashboard up again. The created objects will still exist.

Also see

DVD Library Example

The following example demonstrates how Jetfire can be used to create a DVD library using the 'state' first class construct. The 'state' construct prevents methods, in this example, from being executed when the workflow is not in the proper state. For example the 'Borrow' method can not be executed when the workflow is in the 'Borrowed' state.

There is just one Jetfire workflow class, called 'DVD' required for the solution. DVDs are added to the library by instantiating (new) the DVD workflow class. Individual DVDs can be borrowed and returned using the 'Borrow' and 'Return' methods. The status of each individual DVD is determined by the state, 'CheckedIn' or 'Borrowed'.

The DVD workflow objects are automatically stored in the Jetfire Server Nexus. Any changes to the workflow objects are also automatically saved. Exactly where the objects (and workflow classes) are stored is determined by the Jetfire Nexus Server storage module. The default module stores nexus objects (and classes) in files.

When a DVD workflow is in the 'CheckedIn' state only the 'Borrow' command is public. When the DVD is in the 'Borrowed' state the 'Borrow' command is private. It is the responsibility of the application software to present these commands to the user.

// This code can be selected, copied (cntrl c) and pasted (cntrl v) into the Jetfire dashboard.
//  This is Jetfire script code.  Yes it does look a lot like C#.
namespace DVDLib
{
   // This workflow demonstrates using the 'states' modifier for methods.
   workflow DVD
   {
        // This is a state name CheckedIn- it looks like a constructor
        // Instances of this workflow class with be in one of the defined states.
        CheckedIn()
        {
              // place code here to be executed with the workflow enters the "CheckedIn" state.
         }
        Borrowed(){}
        //  constructor - this is not a state.  
        //  It is a constructor because its name ('DVD') is the same as the workflow name.
        public DVD()
        {
             enterstate CheckedIn();
        }
        // This is a method.  
        // The 'Borrow' method is only public when this workflow state is 'Borrowed'.
        // When this workflow is not in the 'Borrowed'  state the 'Borrow' method is private.
        public void Borrow()
            :states(CheckedIn)
        { 
             enterstate Borrowed();
        }
        public void Return()
             :states(Borrowed)
        {
             enterstate CheckedIn();
        }
        string title = "no title";
        // gets and sets the 'Title' of this DVD instance.
        public string Title{
            get{return this.title;}
            set{this.title = value;}
        }
   }
} 
DVD Library Example code

Enhancing the DVD Workflow Class

In the example only the 'Title' of the DVD is stored. Naturally this could be easily extended to include other attributes such as Genre, Actors, description, etc.

Also the number of states could be extended to include states such as a 'Setup' state, that would require information about the DVD to be entered, 'Lost' state (indicates that the DVD can not be located) or 'BorrowedOverdue'.

Naturally there are a lot of enhancements that can be made to the DVD workflow. What is interesting is that you can start with a simple workflow class, create objects, then enhance the workflow class and upgrade your existing objects to use the enhanced workflow. To acomplish this Jetfire automatically includes versioning of all workflow classes.

See Also